<html>
<head><meta charset="utf-8"><title>miri-testing · t-compiler/const-eval · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/index.html">t-compiler/const-eval</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/miri-testing.html">miri-testing</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="136059504"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/miri-testing/near/136059504" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrew Poelstra <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/miri-testing.html#136059504">(Oct 18 2018 at 17:45)</a>:</h4>
<p>Hi all. In my spare time I've been thinking about how to update <code>cargo miri</code> for the new test framework. We had been scanning functions for #[test] attributes and then running them, but now #[test] is a macro that puts a pointer to the actual test inside a <code>test::TestDescAndFn</code> structure. see <a href="https://github.com/solson/miri/issues/479" target="_blank" title="https://github.com/solson/miri/issues/479">https://github.com/solson/miri/issues/479</a> . This means for miri to run it, it needs to pull the struct apart to find the function pointer then run that. with the existing APIs that i'm aware of, this is pretty difficult to do programmatically without deeply-nested matches or something</p>



<a name="136059572"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/miri-testing/near/136059572" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrew Poelstra <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/miri-testing.html#136059572">(Oct 18 2018 at 17:47)</a>:</h4>
<p>I wonder if I should work on some enormous syntax ext to allow creating (or manipulating, or matching) <code>Mir</code> objects from a DSL, or if that's overkill. is there a simpler way?</p>



<a name="136063444"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/miri-testing/near/136063444" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/miri-testing.html#136063444">(Oct 18 2018 at 18:48)</a>:</h4>
<p>Well.. we have <a href="https://github.com/solson/miri/issues/196#issuecomment-308560942" target="_blank" title="https://github.com/solson/miri/issues/196#issuecomment-308560942">https://github.com/solson/miri/issues/196#issuecomment-308560942</a> which suggests to give us the ability to generate MIR from code. An initial version could be a convenience function that takes a string and produces MIR that we then can interpret to take apart these constants in the desired way</p>



<a name="136068476"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/miri-testing/near/136068476" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrew Poelstra <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/miri-testing.html#136068476">(Oct 18 2018 at 20:12)</a>:</h4>
<p>Thanks Oli! If there are other uses for an ast-to-mir converter then I'll hack on it this weekend and see where I get</p>



<a name="136068612"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/miri-testing/near/136068612" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/miri-testing.html#136068612">(Oct 18 2018 at 20:15)</a>:</h4>
<p>alternatively, why can't we compile the thing that would usually inspect the <code>TestDescAndFn</code> and run that? I mean, rustc produces a binary interpreting that stuff, so there's MIR for it <em>somewhere</em></p>



<a name="136068709"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/miri-testing/near/136068709" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrew Poelstra <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/miri-testing.html#136068709">(Oct 18 2018 at 20:16)</a>:</h4>
<p>We could - the thing is that it runs every test function in a row (like the old test runner) so it would be harder to emit the "Running test::whatever" diagnostics.</p>



<a name="136068758"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/miri-testing/near/136068758" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrew Poelstra <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/miri-testing.html#136068758">(Oct 18 2018 at 20:17)</a>:</h4>
<p>Well, the program itself will output diagnostics; but it would be harder for us to introspect and determine which test we were in the middle of</p>



<a name="136068858"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/miri-testing/near/136068858" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/miri-testing.html#136068858">(Oct 18 2018 at 20:18)</a>:</h4>
<p>we'll need a libstd with MIR</p>



<a name="136068862"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/miri-testing/near/136068862" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/miri-testing.html#136068862">(Oct 18 2018 at 20:19)</a>:</h4>
<p>but then printing to stdout/stderr should work</p>



<a name="136068997"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/miri-testing/near/136068997" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrew Poelstra <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/miri-testing.html#136068997">(Oct 18 2018 at 20:21)</a>:</h4>
<p>What about multithreading?</p>



<a name="136070694"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/miri-testing/near/136070694" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/miri-testing.html#136070694">(Oct 18 2018 at 20:47)</a>:</h4>
<p>that won't work, but does that happen by default?</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>